#pragma once

#include <ostream>

#include "util/char-input-stream.h"
#include "util/stack.h"

#include "md-line-tokenizer.h"


namespace book
{

class ParagraphConvert
{
public:
    ParagraphConvert(CharInputStream &in, std::ostream &out);

    void operator()();

private:
    void handle(const MdToken &tok);

    void handleText(const std::string &text);

    void handleFlag(MdToken::Type type);

    void handleSimpleDecorationFlag(MdToken::Type type);

    void handleCode(const std::string &content);

    void handleUnnamedHref();

    void handleRemainFlag();

private:
    RestorableMdLineTokenizer tokenizer_;
    std::ostream &out_;

private:
    Stack<MdToken::Type> flagStack_;
};

} // namespace book
